package com.youmu.shop.order.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.youmu.shop.base.dao.BaseDao;
import com.youmu.shop.order.bean.OrderBean;
import com.youmu.shop.order.bean.OrderItemBean;
import com.youmu.shop.order.vo.DispatchingOrder;
import com.youmu.shop.order.vo.OrderDetailVo;
import com.youmu.shop.order.vo.OrderVo;
import com.youmu.shop.order.vo.ShippingMethodVo;

/**
 * 订单数据层
 * @author yjh
 *
 */
public interface OrderDao extends BaseDao<OrderBean>{

	/**
	 * 根据订单状态查询订单
	 * @param orderStatus
	 * @param userId
	 * @return
	 */
	List<OrderVo> findOrderByStatus(@Param("orderStatus")Integer orderStatus,@Param("payStatus") Integer payStatus,@Param("shippingStatus") Integer shippingStatus,@Param("userId")Long userId);

	/**
	 * 查询订单明细
	 * @param orderId
	 * @return
	 */
	OrderDetailVo findOrderDetail(@Param("orderId")Long orderId);

	/**
	 * 批量保存订单子项
	 * @param orderItemBeans
	 */
	void batchSaveOrderItemDetail(@Param("list")List<OrderItemBean> orderItemBeans,@Param("orderId")Long orderId);

	/**
	 * 根据外部订单号查找订单
	 * @param outSn
	 * @return
	 */
	OrderBean getByOutSn(@Param("outSn")String outSn);

	/**
	 * 保存订单项
	 * @param orderItemBean
	 */
	void saveOrderItemDetail(OrderItemBean orderItemBean);

	/**
	 * 取消订单
	 */
	void cancelOrder(Long id);

	/**
	 * 根据订单号查询外部物流订单号
	 * @param orderId
	 * @return
	 */
	String getShippingByOrderId(@Param("orderId")Long orderId);

	/**
	 * 根据订单id查询有哪些订单子项
	 * @param orderId
	 * @return
	 */
	OrderBean findItemsByOrderId(@Param("orderId")Long orderId);

	/**
	 * 根据订单id和用户id获取实付款
	 * @param orderId
	 * @param userId
	 * @return
	 */
	Double getPaidAmountByInfo(@Param("orderId")Long orderId, @Param("userId")Long userId);

    /**
     * 
     * @return
     */
    List<ShippingMethodVo> getShippingMethod();

    /**
     * 配送端查询订单
     * @param map
     * @return
     */
    List<DispatchingOrder> selectOrdersForDispatchingAdmin(Map<String, Object> map);
    
    /**
     * 根据订单主键查询订单详情
     * @param orderId
     * @return
     */
    List<OrderItemBean> selectOrderItemsByOrder(Long orderId);
    
    /**
     * 配送端操作人员接单
     * @param orderBean
     * @return
     */
    Integer orderTaking(OrderBean orderBean);
    
    /**
     * 配送人员查询我的工单
     * @param map
     * @return
     */
    List<DispatchingOrder> selectDispatchingByAdmin(Map<String, Object> map);
    
    /**
     * 根据id查询订单
     * @param orderId
     * @return
     */
    OrderBean selectByPrimaryKey(Long orderId);
    
    /**
     * 确认收货
     * @param orderId
     * @return
     */
    Integer confirmReceipt(Long orderId);
    
}
